/*   **********************************************************************  **
 **   Copyright notice                                                       **
 **                                                                          **
 **   (c) 2009, Around(J2)ME				                                 **
 **   All rights reserved.                                                   **
 **                                                                          **
 **   This program and the accompanying materials are made available under   **
 **   the terms of the New BSD License which accompanies this    			 **
 **   distribution.											                 **
 **   A copy is found in the textfile LICENSE.txt							 **
 **                                                                          **
 **   This copyright notice MUST APPEAR in all copies of the file!           **
 **                                                                          **
 **   Main developers:                                                       **
 **     Juri Strumpflohner		http://blog.js-development.com	             **
 **		Matthias Braunhofer		http://matthias.jimdo.com                    **
 **                                                                          **
 **  **********************************************************************  */

package org.aroundme.unittests;

import junit.framework.TestCase;

import org.aroundme.model.Encrypter;

public class EncryptDecryptTest extends TestCase {
	private Encrypter encr;
	
	protected void setUp() throws Exception {
		super.setUp();
		encr = new Encrypter();
	}

	protected void tearDown() throws Exception {
		super.tearDown();
		encr = null;
	}
	
	public void testEncryptDecr(){
		String[][] users = new String[][]{
				{"Firstlife user", "userPass01$"},
				{"kito", "$thisIs$myPassword$!"},
				{"testuser010101", "%heloo%!"}
			};	
		
		for(int i=0; i<users.length; i++){
			byte[] encrypted = encr.encryptPassword(users[i][1]);
			
			String decrypted = encr.performDecrypt(encrypted);
			
			assertEquals("password should match", users[i][1], decrypted);
		}
	}

}
